Merge "Make wfForeignMemcKey consistent with wfMemcKey"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Sat, 3 Aug 2013 05:20:17 +0000 (05:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Sat, 3 Aug 2013 05:20:17 +0000 (05:20 +0000)
1  2 
includes/GlobalFunctions.php

@@@ -130,16 -130,14 +130,16 @@@ function wfArrayDiff2_cmp( $a, $b ) 
  
  /**
   * Array lookup
 - * Returns an array where the values in the first array are replaced by the
 - * values in the second array with the corresponding keys
 + * Returns an array where the values in array $b are replaced by the
 + * values in array $a with the corresponding keys
   *
 + * @deprecated since 1.22; use array_intersect_key()
   * @param $a Array
   * @param $b Array
   * @return array
   */
  function wfArrayLookup( $a, $b ) {
 +      wfDeprecated( __FUNCTION__, '1.22' );
        return array_flip( array_intersect( array_flip( $a ), array_keys( $b ) ) );
  }
  
@@@ -165,13 -163,11 +165,13 @@@ function wfAppendToArrayIfNotDefault( $
   * Backwards array plus for people who haven't bothered to read the PHP manual
   * XXX: will not darn your socks for you.
   *
 + * @deprecated since 1.22; use array_replace()
   * @param $array1 Array
   * @param [$array2, [...]] Arrays
   * @return Array
   */
  function wfArrayMerge( $array1/* ... */ ) {
 +      wfDeprecated( __FUNCTION__, '1.22' );
        $args = func_get_args();
        $args = array_reverse( $args, true );
        $out = array();
@@@ -879,10 -875,10 +879,10 @@@ function wfMakeUrlIndexes( $url ) 
  function wfMatchesDomainList( $url, $domains ) {
        $bits = wfParseUrl( $url );
        if ( is_array( $bits ) && isset( $bits['host'] ) ) {
 +              $host = '.' . $bits['host'];
                foreach ( (array)$domains as $domain ) {
 -                      // FIXME: This gives false positives. http://nds-nl.wikipedia.org will match nl.wikipedia.org
 -                      // We should use something that interprets dots instead
 -                      if ( substr( $bits['host'], -strlen( $domain ) ) === $domain ) {
 +                      $domain = '.' . $domain;
 +                      if ( substr( $host, -strlen( $domain ) ) === $domain ) {
                                return true;
                        }
                }
@@@ -1351,7 -1347,7 +1351,7 @@@ function wfMessage( $key /*...*/) 
   */
  function wfMessageFallback( /*...*/ ) {
        $args = func_get_args();
 -      return MWFunction::callArray( 'Message::newFallbackSequence', $args );
 +      return call_user_func_array( 'Message::newFallbackSequence', $args );
  }
  
  /**
@@@ -2028,11 -2024,9 +2028,11 @@@ function wfEscapeWikiText( $text ) 
  
  /**
   * Get the current unix timestamp with microseconds.  Useful for profiling
 + * @deprecated since 1.22; call microtime() directly
   * @return Float
   */
  function wfTime() {
 +      wfDeprecated( __FUNCTION__, '1.22' );
        return microtime( true );
  }
  
@@@ -3390,7 -3384,7 +3390,7 @@@ function wfForeignMemcKey( $db, $prefi
        } else {
                $key = $db . ':' . implode( ':', $args );
        }
-       return $key;
+       return str_replace( ' ', '_', $key );
  }
  
  /**
@@@ -3756,17 -3750,22 +3756,17 @@@ function wfBCP47( $code ) 
        $codeSegment = explode( '-', $code );
        $codeBCP = array();
        foreach ( $codeSegment as $segNo => $seg ) {
 -              if ( count( $codeSegment ) > 0 ) {
 -                      // when previous segment is x, it is a private segment and should be lc
 -                      if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
 -                              $codeBCP[$segNo] = strtolower( $seg );
 -                      // ISO 3166 country code
 -                      } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
 -                              $codeBCP[$segNo] = strtoupper( $seg );
 -                      // ISO 15924 script code
 -                      } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) {
 -                              $codeBCP[$segNo] = ucfirst( strtolower( $seg ) );
 -                      // Use lowercase for other cases
 -                      } else {
 -                              $codeBCP[$segNo] = strtolower( $seg );
 -                      }
 +              // when previous segment is x, it is a private segment and should be lc
 +              if ( $segNo > 0 && strtolower( $codeSegment[( $segNo - 1 )] ) == 'x' ) {
 +                      $codeBCP[$segNo] = strtolower( $seg );
 +              // ISO 3166 country code
 +              } elseif ( ( strlen( $seg ) == 2 ) && ( $segNo > 0 ) ) {
 +                      $codeBCP[$segNo] = strtoupper( $seg );
 +              // ISO 15924 script code
 +              } elseif ( ( strlen( $seg ) == 4 ) && ( $segNo > 0 ) ) {
 +                      $codeBCP[$segNo] = ucfirst( strtolower( $seg ) );
 +              // Use lowercase for other cases
                } else {
 -              // Use lowercase for single segment
                        $codeBCP[$segNo] = strtolower( $seg );
                }
        }